package org.soc.timesheet.server.domain.service;

import java.util.List;
import org.soc.timesheet.domain.TokenType;
import org.soc.timesheet.domain.repository.TokenTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class TokenTypeServiceImpl implements TokenTypeService {

	@Autowired
	TokenTypeRepository tokenTypeRepository;

	@Override
	public TokenType findByTypeDesc(String tokenType) {
		// TODO Auto-generated method stub
		return tokenTypeRepository.findByTypeDesc(tokenType);
	}

	public long countAllTokenTypes() {
        return TokenType.countTokenTypes();
    }

	public void deleteTokenType(TokenType tokenType) {
        tokenType.remove();
    }

	public TokenType findTokenType(Integer id) {
        return TokenType.findTokenType(id);
    }

	public List<TokenType> findAllTokenTypes() {
        return TokenType.findAllTokenTypes();
    }

	public List<TokenType> findTokenTypeEntries(int firstResult, int maxResults) {
        return TokenType.findTokenTypeEntries(firstResult, maxResults);
    }

	public void saveTokenType(TokenType tokenType) {
        tokenType.persist();
    }

	public TokenType updateTokenType(TokenType tokenType) {
        return tokenType.merge();
    }
}
